<!DOCTYPE html>
<html>
{include file="public/head"}

<body>
    {include file="public/nav"} {include file="public/nav-2"}
    <div class="layui-container">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md8">
                <div style="text-align: center;margin-bottom: 5px;">
                    <span class="layui-badge layui-bg-orange">提交时间:{$code.in_date}</span>
                    <span class="layui-badge layui-bg-black">运行时间:{$code.time}ms</span>
                    <span class="layui-badge layui-bg-blue">运行内存:{$code.memory}K</span>
                    <span {if condition="$code.result==4" } class="layui-badge layui-bg-green" {else/} class="layui-badge layui-bg-red" {/if}>提交结果:{$resultset[$code.result]}</span>
                </div>
                <div style="text-align: center">
                    <a href="{:url('web/Account/info',['user_id'=>$code.user_id])}"><span class="layui-badge layui-bg-orange">提交人:{$code.user_id}</span></a>
                    <a href="{:url('web/Problem/problem',['pid'=>$code.problem_id])}"><span class="layui-badge layui-bg-blue">Problem - {$code.problem_id}</span></a>
                </div>
                <button class="cpoy-btn" onclick="copyToClipboard()" id="input-button" style="left: -1px;position: relative;top: 10px;">复制</button>
               
                <div id="code-content" class="" style='width: auto;margin-top: 20px;'>
                    <textarea style="display:none;">``` 
{:htmlspecialchars($code.source)}
```</textarea>
                </div>
                {if condition="$error!=false"}
                    错误信息:
                <pre>{$error}</pre> {/if}
                <pre id="input-box" class="layui-hide">{:htmlspecialchars($code.source)}</pre>
            </div>
            {include file="public/side-bar"}
        </div>
    </div>
    {include file="public/foot"}
</body>

{include file="public/submit-js"}
<script>
layui.use(['jquery', 'layer'], function() {
    var $ = layui.jquery;
    var layer = layui.layer;
    var content = $("#input-box").text();
    var clipboard = new ClipboardJS('#input-button', {
        text: function() {
            return content;
        }
    });
    clipboard.on('success', function(e) {
        layer.msg('复制成功');
    });

    clipboard.on('error', function(e) {
        layer.msg('您的浏览器不支持复制哦~');
        console.log(e);
    });
});
</script>
<script src="__STATIC__/markdown/examples/js/jquery.min.js"></script>
 <script src="__STATIC__/markdown/editormd.min.js"></script>
 
        <script src="__STATIC__/markdown/lib/marked.min.js"></script>
        <script src="__STATIC__/markdown/lib/prettify.min.js"></script>
        
        <script src="__STATIC__/markdown/lib/raphael.min.js"></script>
        <script src="__STATIC__/markdown/lib/underscore.min.js"></script>
        <script src="__STATIC__/markdown/lib/sequence-diagram.min.js"></script>
        <script src="__STATIC__/markdown/lib/flowchart.min.js"></script>
        <script src="__STATIC__/markdown/lib/jquery.flowchart.min.js"></script>
        
        <script>
            editormd.markdownToHTML('code-content', {
                            htmlDecode      : "style,script,iframe",  // you can filter tags decode
                            emoji           : true,
                            taskList        : true,
                            tex             : true,  // 默认不解析
                            flowChart       : true,  // 默认不解析
                            sequenceDiagram : true,  // 默认不解析
                            path            : "__STATIC__/markdown/lib/",
                        });
        </script>
</html>